package top.jojoace.JPA.model_DDL.OneWay_ManyToMany;

import lombok.Data;

import javax.persistence.*;
import java.util.List;

@Entity
@Data
public class OW_Student {
    @Id
    private int id;
    private Long studentNumber;
    private String name;


    /**
     * 多对多中，两边同时在对应字段中添加@ManyToMany
     *
     * <h1>@JoinTable() 设置中间表，默认没有主键</h1>
     * @JoinTable(name = "student_teacher", //指定中间表别名
     *             joinColumns = @JoinColumn(name = "student_id"), //指定连接名
     *             inverseJoinColumns = @JoinColumn(name = "teacher_id") //指定被连接
     *     )
     *
     */
    @ManyToMany
    @JoinTable(name = "student_teacher",
            joinColumns = @JoinColumn(name = "student_id"),
            inverseJoinColumns = @JoinColumn(name = "teacher_id")
    )
    private List<OW_Teacher> teacherList;
}
